<?php

namespace Biz\model\IkeaActivity;

use Doraemon\pockets\datebase\BaseDbModel;

class IkeaActivityJoinRecordModel extends BaseDbModel
{

    public const _CONFIG_FILE_ = 'db_store';


    public const _CONFIG_SELECT_ = 'db_brand_activity';

    public const _DATABASE_ = 'brand_activity';


    public const _TABLE_NAME = 'ikea_activity_join_record';

    const TYPE_TASK = 1; //任务 完成活动数据
    const TYPE_REMIND = 2;//提醒 设置日历提醒

    const STATUS_NORMAL = 1;
    const STATUS_DELETE = 9;

    const BRAND_ID = 270;
    const TASK_MAP = [
        ['task_id' => 1, 'task_name' => '过腊八', 'date' => '12.30', 'start_time' => 20221229,'toast'=>'活动未开始'],
        ['task_id' => 2, 'task_name' => '大扫除', 'date' => '1.3', 'start_time' => 20230102,'toast'=>'打卡活动未上线，1月2日来浏览定制文章，即可完成打卡'],
        ['task_id' => 3, 'task_name' => '装点家', 'date' => '1.10', 'start_time' => 20230109,'toast'=>'打卡活动未上线，1月9日来浏览宜家话题，即可完成打卡'],
        ['task_id' => 4, 'task_name' => '年夜饭', 'date' => '1.16', 'start_time' => 20230116,'toast'=>'打卡活动未上线，1月16日来点赞住友内容，即可完成打卡'],
        ['task_id' => 5, 'task_name' => '守岁迎新', 'date' => '1.19', 'start_time' => 20230119,'toast'=>'打卡活动未上线，1月19日来领取招福屏保，即可完成打卡'],
    ];

//    const NOTE_ID_MAP = ['0009vzb0000bonyd','0009vwc0000bonvw','0009vxa0000bonvw','0009viy0000bonzz'];//note id qa环境
    const NOTE_ID_MAP = ['0063w130000083uk','0063st50000024qe','0063ufp00000arr2','0063wb100000s9wt','0063xqp00000ipu6','0063zc0000000odm','0063xkl00000abro'];//note id gray/pro

//    const TOPIC_ID = 2363;//话题id qa
    const TOPIC_ID = 1724;//话题id  gray/pro

//    const BLANK_ID = '00017sb05000ewtp';//文章id qa
    const BLANK_ID = '0004xyi0500191vt';//文章id gray/pro

    public static function insertData($data)
    {
        if (!isset($data['addtime'])) {
            $data['addtime'] = date('Y-m-d H:i:s');
        }
        if (!isset($data['edittime'])) {
            $data['edittime'] = date('Y-m-d H:i:s');
        }
        $ret = self::insert($data);
        if ($ret->errorCode() !== '00000') {
            return false;
        }

        return self::id();
    }

    public static function updateDataByWhere($data, $where): bool
    {
        if (!isset($data['edittime'])) {
            $data['edittime'] = date('Y-m-d H:i:s');
        }
        $ret = self::update($data, $where);
        if ($ret->errorCode() !== '00000') {
            return false;
        }

        return true;
    }

    public static function selectByWhere($where, $field = '*'): array
    {
        return self::select($field, $where) ?? [];
    }


    public static function getByWhere($where, $field = '*')
    {
        return self::get($field, $where) ?? [];
    }

}